﻿using System;
using System.Collections.Generic;
using System.Linq;
using H2.NET.Common;
using H2.NET.Data.Common;
using H2.NET.Web.Management.Config.Service;
using H2.NET.Web.Pages.SMD.Model;
using H2.NET.Web.Workflow.DwzCode;

namespace H2.NET.Web.Pages.SMD.InStock
{
    public partial class Index : BasePage
    {
        public string BalanceBudget_SH = string.Empty;
        public string BalanceBudget_GZ = string.Empty;
        public string BalanceBudget_LF = string.Empty;
        private readonly ConfigService _configService = new ConfigService();
        public List<t_smd_InStock> InStocks = new List<t_smd_InStock>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;

            var dt = _configService.GetList("ParentId = (select configid from t_smd_Config where code='S_XYYS')").Tables[0];
            BalanceBudget_SH = Utils.StrToDecimal(dt.Select("code = 'SHXYYS'")[0]["value"].ToString(), 0).ToString("N");
            BalanceBudget_GZ = Utils.StrToDecimal(dt.Select("code = 'GZXYYS'")[0]["value"].ToString(), 0).ToString("N");
            BalanceBudget_LF = Utils.StrToDecimal(dt.Select("code = 'LFXYYS'")[0]["value"].ToString(), 0).ToString("N");

            InStocks = (t_smd_InStock._ID > 0).List<t_smd_InStock>(Storage.Context3).ToList();
        }
    }
}